<?php

namespace App\Http\Controllers\Finance;

use App\Common\SDK\Domain\FenZhangTong;
use App\Common\SDK\Domain\ChinaUms;
use App\Http\Controllers\Controller;
use App\Models\Agent;
use App\Models\AgentRevenue;
use App\Models\AgentTopUpOrder;
use App\Models\DailyReportStatistics;
use App\Models\FinanceSupplier;
use App\Models\PaymentChannelFztwx;
use App\Models\PaymentChannelFztumswx;
use App\Models\PaymentOrder;
use App\Services\AgentRewardRuleSettings;
use App\Services\CacheLockKeyConst;
use App\Services\PaymentService;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log;

class UmsReturnController extends Controller
{
    private $reqData;

    public function __construct(Request $request)
    {
        // 校验数据
        $req = $request->all();
        $this->reqData = $req;
    }

    /**
     * 银联商务微信支付同步返回页面
     */
    public function umsReturn()
    {

        $html = '<!DOCTYPE html>
        <html>
        <head>
            <meta charset="UTF-8">
            <title>GOLD PLAN</title>
            <script type="text/javascript" charset="UTF-8" src="https://wx.gtimg.com/pay_h5/goldplan/js/jgoldplan-1.0.0.js"></script>
        </head>
        <body>
            <div style=" font-size: 2rem; margin: 20px; text-align: center;">支付成功</div>
            <div style="overflow: hidden; margin-bottom: 20px">
                
                <div style="float:left">订单号</div>
                <div style="float:right; font-size: 0.9rem;">' . $this->reqData['sn']. '</div>
            </div>
            <div style="overflow: hidden;margin-bottom: 20px">
                <div style="float: left">金额</div>
                <div style="float:right">' . floatval($this->reqData['amount'] / pow(10, 2)) . '元</div>
            </div>
        </body>
        
        <script type="text/javascript">
            window.onload=function(){
                var mchData = {action: \'onIframeReady\', displayStyle: \'SHOW_CUSTOM_PAGE\'};
                var postData = JSON.stringify(mchData);
                parent.postMessage(postData, \'https://payapp.weixin.qq.com\');
                
                var mchData = {action:\'jumpOut\',jumpOutUrl:\'https://www.ssddjj.com/h5/my\'}
                var postData = JSON.stringify(mchData);
                parent.postMessage(postData, \'https://payapp.weixin.qq.com\');
            }
        </script>
        </html>';

        echo $html;
        exit;
    }
}
